<template>
  <view class="splash-container">
   <!-- <image class="logo" src="/static/logo.png" mode="aspectFit"></image> -->
   <view class="app-name">卜卦</view>
  </view>
</template>

<script>
export default {
	data(){
		return{
			userInfo: {
			  avatar: '',
			  nickname: '',
			  phone: ''
			},
		}
	},
  onLoad() {
	this.loadUserInfo();
	if(this.userInfo.phone){
		this.toIndex();
		return;
	}
	 this.checkPrivacyAgreement()
  },
  
  methods: {
	async loadUserInfo() {
	        // TODO: 加载用户信息
	  	    const loginInfoKey = 'userInfo';
	  	        const storedLoginInfo = uni.getStorageSync(loginInfoKey);
	  	        if (storedLoginInfo) {
	  	          this.userInfo = JSON.parse(storedLoginInfo);
	  	        }
	  },
    async checkPrivacyAgreement() {
      const agreed = uni.getStorageSync('privacy_agreed')
      
      setTimeout(() => {
        if (!agreed) {
			console.log("开始登录..showPrivacy.")
          uni.redirectTo({
            url: '/pages/login/login?showPrivacy=true'
          })
        } else {
			console.log("开始登录...")
          uni.redirectTo({
            url: '/pages/login/login'
          })
        }
      }, 1000) // 1秒后跳转
    },
	toIndex(){
		uni.switchTab({
		  url: '/pages/index/index',
		    success: () => {
		      console.log('跳转成功')
		    },
		    fail: (err) => {
		      console.error('跳转失败:', err)
		    }
		  })   
	},
  }
}
</script>

<style lang="scss" scoped>
.splash-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  
  .logo {
    width: 200rpx;
    height: 200rpx;
  }
  
  .app-name {
    margin-top: 30rpx;
    font-size: 36rpx;
    font-weight: bold;
    color: #333;
  }
}
</style>